package serviceimpl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import beans.PersonInformation;
import beans.Searcher;
import daoIpmt.SearchIpmt;
import service.SearchPeople;

public class SearchPeopleIpmt implements SearchPeople {
	SearchIpmt x = new SearchIpmt();

	@Override
	public List<PersonInformation> searchPeople(Searcher search) {
		Date date=new Date();
		SimpleDateFormat format = new SimpleDateFormat("yyyy");
		String str = format.format(date);
		Integer year1=Integer.valueOf(str);
		String age1 = search.getAge1();
		String age2 = search.getAge2();
		Integer year2=year1-(Integer.valueOf(age2));
		Integer year3=year1-Integer.valueOf(age1);
		String dateStart=""+year2+"-01-01";
		String dateEnd=""+year3+"-12-31";
		search.setDateStart(dateStart);
		search.setDateEnd(dateEnd);
		return x.findMemberBySearch(search);
	}

	@Override
	public List<PersonInformation> findMemberByGendar(String gendar) {
		return 		x.findMemberByGendar(gendar);
	}

	public PersonInformation findMemberByusername(String followusername) {
		return x.findMemberByUsername(followusername);
	}
}
